package cs4game;



import java.util.HashMap;
import java.util.Map;

public class BlockDefs {
	public static Map<Integer, BlockID> defs = new HashMap<Integer, BlockID>();
	static boolean initialized = false;
	
	public static void initialize(){
		initialized = true;
		
		defs.put(0x000, new BlockID(new double[0][0][0][0])); // AIR

		//Cobblestone
		
		
		defs.put(0x001, getIDFromTerrain(1, 0));

		//Dirt
		defs.put(0x002, getIDFromTerrain(1, 9));
	}
	
	public static BlockID get(Integer i){
		if(!initialized)
			initialize();
		return defs.get(i);
	}
	public static BlockID getIDFromTerrain (int x, int y){//give me the x and y of the top left corner of the block you want from the terrain grid and i will give you a block id for it.
		
		return new BlockID(new double[][][][]{
				{
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}}
				}, 	
				{
					{{-0.5, -0.5, -0.5}, {0.5, -0.5, -0.5}, {0.5, -0.5, 0.5}, {-0.5, -0.5, 0.5}},
					{{-0.5, -0.5, -0.5}, {0.5, -0.5, -0.5}, {0.5, 0.5, -0.5}, {-0.5, 0.5, -0.5}},
					{{0.5, -0.5, -0.5}, {0.5, -0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, 0.5, -0.5}},
					{{0.5, -0.5, 0.5}, {-0.5, -0.5, 0.5}, {-0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}},
					{{-0.5, -0.5, 0.5}, {-0.5, -0.5, -0.5}, {-0.5, 0.5, -0.5}, {-0.5, 0.5, 0.5}},
					{{-0.5, 0.5, -0.5}, {0.5, 0.5, -0.5}, {0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5}},
				}
		});
	}
	
public static double[][][][] get4DFromTerrain (int x, int y, double length){//give me the x and y of the top left corner of the block you want from the terrain grid and i will give you a block id for it.
		
		return new double[][][][]{
				{
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}},
					{{x/16.0, y/16.0}, {(x+1)/16.0, y/16.0}, {(x+1)/16.0, (y+1)/16.0}, {x/16.0, (y+1)/16.0}}
				}, 	
				{
					{{-length/2, -length/2, -length/2}, {length/2, -length/2, -length/2}, {length/2, -length/2, length/2}, {-length/2, -length/2, length/2}},
					{{-length/2, -length/2, -length/2}, {length/2, -length/2, -length/2}, {length/2, length/2, -length/2}, {-length/2, length/2, -length/2}},
					{{length/2, -length/2, -length/2}, {length/2, -length/2, length/2}, {length/2, length/2, length/2}, {length/2, length/2, -length/2}},
					{{length/2, -length/2, length/2}, {-length/2, -length/2, length/2}, {-length/2, length/2, length/2}, {length/2, length/2, length/2}},
					{{-length/2, -length/2, length/2}, {-length/2, -length/2, -length/2}, {-length/2, length/2, -length/2}, {-length/2, length/2, length/2}},
					{{-length/2, length/2, -length/2}, {length/2, length/2, -length/2}, {length/2, length/2, length/2}, {-length/2, length/2, length/2}},
				}
		};
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
